import { deleted, get, postFormData, putFormData } from '@/utils/request'
import type { SearchField, PageResult, Article } from '@/types'
export const getArticleList = async (search: SearchField): Promise<PageResult<Article>> => {
  const data = await get('/my/article/list', search)
  return data as unknown as PageResult<Article>
}

export const delArticle = async (id: number) => {
  await deleted('/my/article/info', { id: id })
}

export const getArticle = async (id: number): Promise<Article> => {
  const data = await get('/my/article/info', { id: id })
  return data.data as unknown as Article
}

export const addArticle = async (info: Article) => {
  await postFormData('/my/article/add', info)
}

export const updateArticle = async (info: Article) => {
  await putFormData('/my/article/info', info)
}
